/*
 * Camera.h
 *
 *  Created on: 04.06.2011
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#ifndef CAMERA_H_
#define CAMERA_H_

#include "../BasicTypes.h"
#include "../Manager Resource/IUnit.h"
#include "glm/gtx/quaternion.hpp"

using namespace glm;

class CGameCamera
{
private:
	std::vector<IUnit*> bindedUnits;
	glm::quat orienatation;
	glm::mat4 translationMatrix;

	GAME_CAMERA currentGameCamera;
protected:
	void CalculateInitParams( vec3 Eye, glm::quat Orientation );
	void CalculateClipPlanes( glm::vec4 *Frustum, const glm::mat4 &ViewProjMatrix );
	glm::vec4 CalculateClipSphere( const glm::vec3 &LookAt, const float ZNear, const float ZFar,const float Fovy );
public:
	CGameCamera();
	CGameCamera( vec3 Eye, glm::quat Orientation );
	~CGameCamera(){};

	GAME_CAMERA* GetCurrentCamera() const { return new GAME_CAMERA(currentGameCamera); } //Always free returned camera object
	void Translate( const float dx, const float dy, const float dz );
	void RotateEyeAroundPoint( const vec3 Point, const float angelX, const float angelY, const float angelZ );
	void RotateCenterAroundEye( const float angelX, const float angelY, const float angelZ );

	void SetLightDirection( const glm::vec3 LightDirection ){ currentGameCamera.lightDirection = LightDirection; };
	void SetAmblientColor( const glm::vec3 AmblientColor ){ currentGameCamera.amblientColor = AmblientColor; };

	UINT BindUnit( IUnit *Unit );
};

#endif /* CAMERA_H_ */
